home *** CD-ROM | disk | FTP | other *** search
- property _me, pSelectChannel, pGrayChannel1, pGrayChannel2, pSelectionRect, pGrayRect1, pGrayRect2, pVSlider, pUpButton, pDownButton, pTracking, pEditCell, pEditField, pEditFieldChannel, pColumnIsVisible, pBody, pRowHeader, pColumnHeader, pCorner
- global gGraphWizard, gGraph
-
- on new me, selectChannel, grayChannel1, grayChannel2, vSlider, upButton, downButton, fieldName, castName, fieldChannel, body, colHeader, rowHeader, corner, descendant
- if objectp(descendant) then
- _me = descendant
- else
- _me = me
- end if
- pSelectChannel = selectChannel
- pGrayChannel1 = grayChannel1
- pGrayChannel2 = grayChannel2
- pVSlider = vSlider
- pUpButton = upButton
- pDownButton = downButton
- pEditField = member(fieldName, castName)
- pEditFieldChannel = fieldChannel
- pBody = body
- pRowHeader = rowHeader
- pColumnHeader = colHeader
- pCorner = corner
- pSelectionRect = rect(-1, -1, -1, -1)
- pGrayRect1 = rect(-1, -1, -1, -1)
- pGrayRect2 = rect(-1, -1, -1, -1)
- pTracking = 0
- pEditCell = point(-1, -1)
- return me
- end
-
- on condemn me
- _me = 0
- return me
- end
-
- on setSuperTable me
- setSuperTable(pBody, _me)
- setSuperTable(pRowHeader, _me)
- setSuperTable(pColumnHeader, _me)
- setSuperTable(pCorner, _me)
- return me
- end
-
- on setColumnIsVisible me, isVisible
- pColumnIsVisible = isVisible
- setIsVisible(pColumnHeader, isVisible)
- setIsVisible(pCorner, isVisible)
- return me
- end
-
- on Inscope me
- puppetSprite(pSelectChannel, 1)
- puppetSprite(pGrayChannel1, 1)
- puppetSprite(pGrayChannel2, 1)
- puppetSprite(pEditFieldChannel, 1)
- return me
- end
-
- on outScope me
- resetSelection(_me)
- pEditCell = point(-1, -1)
- puppetSprite(pSelectChannel, 0)
- puppetSprite(pGrayChannel1, 0)
- puppetSprite(pGrayChannel2, 0)
- puppetSprite(pEditFieldChannel, 0)
- return me
- end
-
- on showMe me
- set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
- set the rect of sprite pGrayChannel1 to getVisRect(_me, pGrayRect1)
- set the rect of sprite pGrayChannel2 to getVisRect(_me, pGrayRect2)
- updateStage()
- return me
- end
-
- on hideMe me
- set the rect of sprite pSelectChannel to rect(0, 0, 0, 0)
- set the rect of sprite pGrayChannel1 to rect(0, 0, 0, 0)
- set the rect of sprite pGrayChannel2 to rect(0, 0, 0, 0)
- updateStage()
- return me
- end
-
- on trackMouse me, startCell
- pTracking = 1
- resetSelection(me._me)
- c = point(-1, -1)
- currCell = startCell
- setSelectionRect(me._me, startCell, currCell)
- repeat while the mouseDown
- currCell = getCurrCell(me._me, the mouseH, the mouseV)
- if c <> currCell then
- setSelectionRect(me._me, startCell, currCell)
- set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
- updateStage()
- c = currCell
- end if
- end repeat
- setSelectionRect(me._me, startCell, currCell)
- set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
- repeat with i in getCutCopyPasteList(gGraphWizard)
- enable(i)
- end repeat
- updateStage()
- pEditCell = startCell
- showEditField(_me)
- pTracking = 0
- return me
- end
-
- on getCurrCell me, h, v
- if isAbove(pBody, v) then
- if isLeftOf(pBody, h) then
- if not minReached(pVSlider) then
- simulateClickOn(pUpButton)
- mouseCell = getMouseCell(pRowHeader, h, v)
- currCell = point(0, getAt(mouseCell, 2))
- else
- if pColumnIsVisible then
- currCell = point(0, 0)
- else
- currCell = point(0, 1)
- end if
- end if
- else
- if not minReached(pVSlider) then
- simulateClickOn(pUpButton)
- currCell = getMouseCell(pBody, h, v)
- else
- if pColumnIsVisible then
- mouseCell = getMouseCell(pColumnHeader, h, v)
- currCell = point(getAt(mouseCell, 1), 0)
- else
- currCell = getMouseCell(pBody, h, v)
- end if
- end if
- end if
- else
- if not isBelow(pBody, v) then
- if isLeftOf(pBody, h) then
- mouseCell = getMouseCell(pRowHeader, h, v)
- currCell = point(0, getAt(mouseCell, 2))
- else
- currCell = getMouseCell(pBody, h, v)
- end if
- else
- if isLeftOf(pBody, h) then
- if not maxReached(pVSlider) then
- simulateClickOn(pDownButton)
- end if
- mouseCell = getMouseCell(pRowHeader, h, v)
- currCell = point(0, getAt(mouseCell, 2))
- else
- if not maxReached(pVSlider) then
- simulateClickOn(pDownButton)
- end if
- currCell = getMouseCell(pBody, h, v)
- end if
- end if
- end if
- return currCell
- end
-
- on doRollover me
- return me
- end
-
- on scrollUp me
- if not atTop(pBody) then
- scrollUp(pBody)
- scrollUp(pRowHeader)
- set the rect of sprite pGrayChannel1 to getVisRect(_me, pGrayRect1)
- set the rect of sprite pGrayChannel2 to getVisRect(_me, pGrayRect2)
- if not pTracking then
- set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
- if isEditCellVisible(_me) then
- showEditField(_me)
- else
- hideEditField(_me)
- end if
- end if
- updateStage()
- end if
- return me
- end
-
- on scrollDown me
- if not atBottom(pBody) then
- scrollDown(pBody)
- scrollDown(pRowHeader)
- set the rect of sprite pGrayChannel1 to getVisRect(_me, pGrayRect1)
- set the rect of sprite pGrayChannel2 to getVisRect(_me, pGrayRect2)
- if not pTracking then
- set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
- if isEditCellVisible(_me) then
- showEditField(_me)
- else
- hideEditField(_me)
- end if
- end if
- updateStage()
- end if
- return me
- end
-
- on getTopRow me
- return getTopRow(pBody)
- end
-
- on getLeftColumn me
- return getLeftColumn(pBody)
- end
-
- on resetSelection me
- hideEditField(_me)
- pSelectionRect = rect(-1, -1, -1, -1)
- set the rect of sprite pSelectChannel to rect(0, 0, 0, 0)
- updateStage()
- return me
- end
-
- on setSelectionRect me, cell1, cell2
- p1 = duplicate(cell1)
- p2 = duplicate(cell2)
- if getAt(p1, 1) > getAt(p2, 1) then
- temp = getAt(p2, 1)
- setAt(p2, 1, getAt(p1, 1))
- setAt(p1, 1, temp)
- end if
- if getAt(p1, 2) > getAt(p2, 2) then
- temp = getAt(p2, 2)
- setAt(p2, 2, getAt(p1, 2))
- setAt(p1, 2, temp)
- end if
- pSelectionRect = rect(p1, p2)
- return me
- end
-
- on getVisRect me, theRect
- R = rect(0, 0, 0, 0)
- if theRect <> rect(-1, -1, -1, -1) then
- if (theRect.left > 0) and (theRect.top > 0) then
- R = getVisRect(pBody, theRect)
- end if
- if (theRect.left = 0) and (theRect.top > 0) then
- r1 = getVisRect(pRowHeader, rect(1, getAt(theRect, 2), 1, getAt(theRect, 4)))
- r2 = getVisRect(pBody, rect(1, getAt(theRect, 2), getAt(theRect, 3), getAt(theRect, 4)))
- R = unionVisRect(_me, r1, r2)
- end if
- if (theRect.left > 0) and (theRect.top = 0) then
- r1 = getVisRect(pColumnHeader, rect(getAt(theRect, 1), 1, getAt(theRect, 3), 1))
- r2 = getVisRect(pBody, rect(getAt(theRect, 1), 1, getAt(theRect, 3), getAt(theRect, 4)))
- R = unionVisRect(_me, r1, r2)
- end if
- if (theRect.left = 0) and (theRect.top = 0) then
- r1 = getVisRect(pCorner, rect(1, 1, 1, 1))
- if (theRect.right = 0) and (theRect.bottom = 0) then
- nothing()
- else
- if theRect.right = 0 then
- r2 = getVisRect(pRowHeader, rect(1, getAt(theRect, 2), 1, getAt(theRect, 4)))
- else
- if theRect.bottom = 0 then
- r2 = getVisRect(pColumnHeader, rect(getAt(theRect, 1), 1, getAt(theRect, 3), 1))
- else
- r2 = getVisRect(pBody, rect(1, 1, getAt(theRect, 3), getAt(theRect, 4)))
- r3 = getVisRect(pRowHeader, rect(1, getAt(theRect, 2), 1, getAt(theRect, 4)))
- r4 = getVisRect(pColumnHeader, rect(getAt(theRect, 1), 1, getAt(theRect, 3), 1))
- r2 = unionVisRect(_me, r2, r3)
- r2 = unionVisRect(_me, r2, r4)
- end if
- end if
- end if
- R = unionVisRect(_me, r1, r2)
- end if
- end if
- return R
- end
-
- on unionVisRect me, rect1, rect2
- R = rect(0, 0, 0, 0)
- if voidp(rect1) or (rect1 = rect(0, 0, 0, 0)) then
- return rect2
- else
- if voidp(rect2) or (rect2 = rect(0, 0, 0, 0)) then
- return rect1
- else
- return union(rect1, rect2)
- end if
- end if
- end
-
- on setGrayRegion me, chartType
- case chartType of
- 0:
- pGrayRect1 = rect(2, 1, 5, 30)
- pGrayRect2 = rect(0, 11, 1, 30)
- 1:
- pGrayRect1 = rect(2, 1, 5, 30)
- pGrayRect2 = rect(-1, -1, -1, -1)
- 2:
- pGrayRect1 = rect(2, 1, 5, 25)
- pGrayRect2 = rect(0, 26, 5, 30)
- 3:
- pGrayRect1 = rect(0, 21, 5, 30)
- pGrayRect2 = rect(-1, -1, -1, -1)
- 4:
- pGrayRect1 = rect(0, 6, 5, 30)
- pGrayRect2 = rect(-1, -1, -1, -1)
- end case
- return me
- end
-
- on isNumberCell me
- return (getAt(pEditCell, 1) > 0) and (getAt(pEditCell, 2) > 0)
- end
-
- on isEditCellVisible me
- if pEditCell <> point(-1, -1) then
- if pEditCell = point(0, 0) then
- cell = point(1, 1)
- subtable = pCorner
- else
- if getAt(pEditCell, 1) = 0 then
- cell = duplicate(pEditCell)
- setAt(cell, 1, 1)
- subtable = pRowHeader
- else
- if getAt(pEditCell, 2) = 0 then
- cell = duplicate(pEditCell)
- setAt(cell, 2, 1)
- subtable = pColumnHeader
- else
- cell = pEditCell
- subtable = pBody
- end if
- end if
- end if
- editRect = getCellRect(subtable, cell)
- if not voidp(editRect) then
- return isEditCellVisible(subtable, cell)
- else
- return 0
- end if
- else
- return 0
- end if
- end
-
- on showEditField me
- if pEditCell <> point(-1, -1) then
- if pEditCell = point(0, 0) then
- cell = point(1, 1)
- subtable = pCorner
- else
- if getAt(pEditCell, 1) = 0 then
- cell = duplicate(pEditCell)
- setAt(cell, 1, 1)
- subtable = pRowHeader
- else
- if getAt(pEditCell, 2) = 0 then
- cell = duplicate(pEditCell)
- setAt(cell, 2, 1)
- subtable = pColumnHeader
- else
- cell = pEditCell
- subtable = pBody
- end if
- end if
- end if
- editRect = getCellRect(subtable, cell)
- theContents = getCellContents(subtable, cell)
- member(pEditField).text = theContents
- if not voidp(editRect) then
- if isCellVisible(subtable, editRect) then
- n = the number of chars in theContents
- sprite(pEditFieldChannel).visible = 0
- updateStage()
- set the rect of sprite pEditFieldChannel to editRect
- sprite(pEditFieldChannel).visible = 1
- updateStage()
- hilite char 1 to n of field pEditField
- else
- hideEditField(_me)
- end if
- else
- hideEditField(_me)
- end if
- end if
- return me
- end
-
- on hideEditField me
- if pEditCell <> point(-1, -1) then
- if pEditCell = point(0, 0) then
- cell = point(1, 1)
- subtable = pCorner
- else
- if getAt(pEditCell, 1) = 0 then
- cell = duplicate(pEditCell)
- setAt(cell, 1, 1)
- subtable = pRowHeader
- else
- if getAt(pEditCell, 2) = 0 then
- cell = duplicate(pEditCell)
- setAt(cell, 2, 1)
- subtable = pColumnHeader
- else
- cell = pEditCell
- subtable = pBody
- end if
- end if
- end if
- setCellContents(subtable, cell, member(pEditField).text)
- end if
- sprite(pEditFieldChannel).visible = 0
- updateStage()
- set the loc of sprite pEditFieldChannel to point(-9999, -9999)
- sprite(pEditFieldChannel).visible = 1
- updateStage()
- return me
- end
-
- on getBodyData me
- return getData(pBody)
- end
-
- on getData me
- theData = []
- if getaProp(gGraph, #pChartType) > 2 then
- append(theData, getData(pCorner))
- append(theData, getData(pColumnHeader))
- end if
- append(theData, getData(pRowHeader))
- append(theData, getData(pBody))
- return theData
- end
-
- on setData me, theData
- if getaProp(gGraph, #pChartType) > 2 then
- setData(pCorner, getAt(theData, 1))
- setData(pColumnHeader, getAt(theData, 2))
- setData(pRowHeader, getAt(theData, 3))
- setData(pBody, getAt(theData, 4))
- else
- setData(pRowHeader, getAt(theData, 1))
- setData(pBody, getAt(theData, 2))
- end if
- return me
- end
-
- on getColumnHeader me
- return getData(pColumnHeader)
- end
-
- on getRowHeader me
- return getData(pRowHeader)
- end
-
- on checkIfSelected me
- return pSelectionRect <> rect(-1, -1, -1, -1)
- end
-
- on checkPasteDataSize me, dataList
- R = getAt(dataList, 1)
- if pSelectionRect = rect(-1, -1, -1, -1) then
- return 0
- else
- return ((R.right - R.left) <= (getNumColumns(pBody) - pSelectionRect.left)) and ((R.bottom - R.top) <= (getNumRows(pBody) - pSelectionRect.top))
- end if
- end
-
- on cutSelectedData me
- hideEditField(_me)
- if pSelectionRect <> rect(-1, -1, -1, -1) then
- dataList = []
- append(dataList, pSelectionRect)
- if (pSelectionRect.left > 0) and (pSelectionRect.top > 0) then
- append(dataList, cutSelectedData(pBody, pSelectionRect))
- else
- if (pSelectionRect.left > 0) and (pSelectionRect.top = 0) then
- data = cutSelectedData(pColumnHeader, rect(getAt(pSelectionRect, 1), 1, getAt(pSelectionRect, 3), 1))
- data = quickUnion(data, cutSelectedData(pBody, rect(getAt(pSelectionRect, 1), 1, getAt(pSelectionRect, 3), getAt(pSelectionRect, 4))))
- append(dataList, data)
- else
- if (pSelectionRect.left = 0) and (pSelectionRect.top > 0) then
- data = []
- rowData = cutSelectedData(pRowHeader, rect(1, getAt(pSelectionRect, 2), 1, getAt(pSelectionRect, 4)))
- bodyData = cutSelectedData(pBody, rect(1, getAt(pSelectionRect, 2), getAt(pSelectionRect, 3), getAt(pSelectionRect, 4)))
- numRows = getAt(pSelectionRect, 4) - getAt(pSelectionRect, 2) + 1
- numCols = getAt(pSelectionRect, 3)
- repeat with i = 1 to numRows
- append(data, getAt(rowData, i))
- repeat with j = 1 to numCols
- append(data, getAt(bodyData, ((i - 1) * numCols) + j))
- end repeat
- end repeat
- append(dataList, data)
- else
- data = cutSelectedData(pCorner, rect(1, 1, 1, 1))
- data = quickUnion(data, cutSelectedData(pColumnHeader, rect(1, 1, getAt(pSelectionRect, 3), 1)))
- rowData = cutSelectedData(pRowHeader, rect(1, 1, 1, getAt(pSelectionRect, 4)))
- bodyData = cutSelectedData(pBody, rect(1, 1, getAt(pSelectionRect, 3), getAt(pSelectionRect, 4)))
- numRows = getAt(pSelectionRect, 4)
- numCols = getAt(pSelectionRect, 3)
- repeat with i = 1 to numRows
- append(data, getAt(rowData, i))
- repeat with j = 1 to numCols
- append(data, getAt(bodyData, ((i - 1) * numCols) + j))
- end repeat
- end repeat
- append(dataList, data)
- end if
- end if
- end if
- end if
- showEditField(_me)
- return dataList
- end
-
- on getSelectedData me
- hideEditField(_me)
- if pSelectionRect <> rect(-1, -1, -1, -1) then
- dataList = []
- append(dataList, pSelectionRect)
- if (pSelectionRect.left > 0) and (pSelectionRect.top > 0) then
- append(dataList, getSelectedData(pBody, pSelectionRect))
- else
- if (pSelectionRect.left > 0) and (pSelectionRect.top = 0) then
- data = getSelectedData(pColumnHeader, rect(getAt(pSelectionRect, 1), 1, getAt(pSelectionRect, 3), 1))
- data = quickUnion(data, getSelectedData(pBody, rect(getAt(pSelectionRect, 1), 1, getAt(pSelectionRect, 3), getAt(pSelectionRect, 4))))
- append(dataList, data)
- else
- if (pSelectionRect.left = 0) and (pSelectionRect.top > 0) then
- data = []
- rowData = getSelectedData(pRowHeader, rect(1, getAt(pSelectionRect, 2), 1, getAt(pSelectionRect, 4)))
- bodyData = getSelectedData(pBody, rect(1, getAt(pSelectionRect, 2), getAt(pSelectionRect, 3), getAt(pSelectionRect, 4)))
- numRows = getAt(pSelectionRect, 4) - getAt(pSelectionRect, 2) + 1
- numCols = getAt(pSelectionRect, 3)
- repeat with i = 1 to numRows
- append(data, getAt(rowData, i))
- repeat with j = 1 to numCols
- append(data, getAt(bodyData, ((i - 1) * numCols) + j))
- end repeat
- end repeat
- append(dataList, data)
- else
- data = getSelectedData(pCorner, rect(1, 1, 1, 1))
- data = quickUnion(data, getSelectedData(pColumnHeader, rect(1, 1, getAt(pSelectionRect, 3), 1)))
- rowData = getSelectedData(pRowHeader, rect(1, 1, 1, getAt(pSelectionRect, 4)))
- bodyData = getSelectedData(pBody, rect(1, 1, getAt(pSelectionRect, 3), getAt(pSelectionRect, 4)))
- numRows = getAt(pSelectionRect, 4)
- numCols = getAt(pSelectionRect, 3)
- repeat with i = 1 to numRows
- append(data, getAt(rowData, i))
- repeat with j = 1 to numCols
- append(data, getAt(bodyData, ((i - 1) * numCols) + j))
- end repeat
- end repeat
- append(dataList, data)
- end if
- end if
- end if
- end if
- showEditField(_me)
- return dataList
- end
-
- on setSelectedData me, dataList
- hideEditField(_me)
- theRect = getAt(dataList, 1)
- R = rect(-1, -1, -1, -1)
- R.left = pSelectionRect.left
- R.top = pSelectionRect.top
- R.right = pSelectionRect.left + (theRect.right - theRect.left)
- R.bottom = pSelectionRect.top + (theRect.bottom - theRect.top)
- numRows = R.bottom - R.top + 1
- numCols = R.right - R.left + 1
- data = getAt(dataList, 2)
- if (R.left > 0) and (R.top > 0) then
- setSelectedData(pBody, R, data)
- else
- if (R.left > 0) and (R.top = 0) then
- colData = getSubList(data, 1, numCols)
- setSelectedData(pColumnHeader, rect(getAt(R, 1), 1, getAt(R, 3), 1), colData)
- bodyData = getSubList(data, numCols + 1, count(data))
- setSelectedData(pBody, rect(getAt(R, 1), 1, getAt(R, 3), getAt(R, 4)), bodyData)
- else
- if (R.left = 0) and (R.top > 0) then
- rowData = []
- bodyData = []
- repeat with i = 1 to numRows
- append(rowData, getAt(data, (numCols * (i - 1)) + 1))
- bodyData = quickUnion(bodyData, getSubList(data, (numCols * (i - 1)) + 2, numCols * i))
- end repeat
- setSelectedData(pRowHeader, rect(1, getAt(R, 2), 1, getAt(R, 4)), rowData)
- setSelectedData(pBody, rect(1, getAt(R, 2), getAt(R, 3), getAt(R, 4)), bodyData)
- else
- setSelectedData(pCorner, rect(1, 1, 1, 1), getSubList(data, 1, 1))
- colData = getSubList(data, 2, numCols)
- setSelectedData(pColumnHeader, rect(1, 1, getAt(R, 3), 1), colData)
- rowData = []
- bodyData = []
- repeat with i = 2 to numRows
- append(rowData, getAt(data, (numCols * (i - 1)) + 1))
- bodyData = quickUnion(bodyData, getSubList(data, (numCols * (i - 1)) + 2, numCols * i))
- end repeat
- setSelectedData(pRowHeader, rect(1, 1, 1, getAt(R, 4)), rowData)
- setSelectedData(pBody, rect(1, 1, getAt(R, 3), getAt(R, 4)), bodyData)
- end if
- end if
- end if
- showEditField(_me)
- return dataList
- end
-
- on moveLeft me
- if (pEditCell <> point(-1, -1)) and (getAt(pEditCell, 1) > 0) then
- hideEditField(_me)
- setAt(pEditCell, 1, getAt(pEditCell, 1) - 1)
- setSelectionRect(_me, pEditCell, pEditCell)
- set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
- updateStage()
- showEditField(_me)
- end if
- return me
- end
-
- on moveUp me
- if pColumnIsVisible then
- canStillGoUp = getAt(pEditCell, 2) > 0
- else
- canStillGoUp = getAt(pEditCell, 2) > 1
- end if
- if (pEditCell <> point(-1, -1)) and canStillGoUp then
- hideEditField(_me)
- setAt(pEditCell, 2, getAt(pEditCell, 2) - 1)
- setSelectionRect(_me, pEditCell, pEditCell)
- set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
- updateStage()
- if getAt(pEditCell, 2) < getTopRow(pBody) then
- simulateClickOn(pUpButton)
- end if
- showEditField(_me)
- end if
- return me
- end
-
- on MoveRight me
- if (pEditCell <> point(-1, -1)) and (getAt(pEditCell, 1) < getNumColumns(pBody)) then
- hideEditField(_me)
- setAt(pEditCell, 1, getAt(pEditCell, 1) + 1)
- setSelectionRect(_me, pEditCell, pEditCell)
- set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
- updateStage()
- showEditField(_me)
- end if
- return me
- end
-
- on moveDown me
- if (pEditCell <> point(-1, -1)) and (getAt(pEditCell, 2) < getNumRows(pBody)) then
- hideEditField(_me)
- setAt(pEditCell, 2, getAt(pEditCell, 2) + 1)
- setSelectionRect(_me, pEditCell, pEditCell)
- set the rect of sprite pSelectChannel to getVisRect(_me, pSelectionRect)
- updateStage()
- if getAt(pEditCell, 2) > getBottomRow(pBody) then
- simulateClickOn(pDownButton)
- end if
- showEditField(_me)
- end if
- return me
- end
-